package com.personal.system.controller.content.web;

import com.personal.common.result.Result;
import com.personal.system.service.content.web.ApiArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/blog/v1/article")
@Api(tags = "文章API-V1")
@RequiredArgsConstructor
public class ApiArticleController {

    private final ApiArticleService articleService;

    @GetMapping(value = "/")
    @ApiOperation(value = "文章列表", httpMethod = "GET", response = Result.class, notes = "文章列表")
    public Result selectArticleList(Integer categoryId,Integer tagId,String orderByDescColumn) {
        return  articleService.selectArticleList(categoryId,tagId,orderByDescColumn);
    }

    @GetMapping(value = "/info")
    @ApiOperation(value = "文章详情", httpMethod = "GET", response = Result.class, notes = "文章详情")
    public Result selectArticleInfo(Integer id) {
        return articleService.selectArticleInfo(id);
    }

    @GetMapping(value = "/selectUserInfoByArticleId")
    @ApiOperation(value = "根据文章id获取作者信息", httpMethod = "GET", response = Result.class, notes = "根据文章id获取作者信息")
    public Result selectUserInfoByArticleId(Integer id) {
        return articleService.selectUserInfoByArticleId(id);
    }
//
//    @GetMapping(value = "/search")
//    @ApiOperation(value = "用户搜索文章", httpMethod = "GET", response = Result.class, notes = "用户搜索文章")
//    public Result searchArticle(String keyword) {
//        return articleService.searchArticle(keyword);
//    }
//
//    @GetMapping(value = "/archive")
//    @ApiOperation(value = "归档", httpMethod = "GET", response = Result.class, notes = "归档")
//    public Result archive() {
//        return  articleService.archive();
//    }


    @GetMapping(value = "/like")
    @ApiOperation(value = "文章点赞", httpMethod = "GET", response = Result.class, notes = "文章点赞")
    public Result articleLike(Integer articleId) {

        return articleService.articleLike(articleId);
    }
//
//    @GetMapping(value = "/checkCode")
//    @ApiOperation(value = "校验公众号验证码", httpMethod = "GET", response = Result.class, notes = "校验公众号验证码")
//    public Result checkCode(String code) {
//        return articleService.checkCode(code);
//    }
//
//    @PostMapping(value = "/")
//    @ApiOperation(value = "添加文章", httpMethod = "POST", response = Result.class, notes = "添加文章")
//    public Result insertArticle(@RequestBody ArticleInsertDTO dto) {
//        return articleService.insertArticle(dto);
//    }
//
//
    @GetMapping(value = "/selectMyArticle")
    @ApiOperation(value = "查询我的文章", httpMethod = "GET", response = Result.class, notes = "查询我的文章")
    public Result selectMyArticle(Integer type) {
        return articleService.selectMyArticle(type);
    }
//
//    @DeleteMapping(value = "/")
//    @ApiOperation(value = "删除我的文章", httpMethod = "DELETE", response = Result.class, notes = "删除我的文章")
//    public Result deleteMyArticle(Long id) {
//        return articleService.deleteMyArticle(id);
//    }
//
//    @GetMapping(value = "/selectMyArticleInfo")
//    @ApiOperation(value = "我的文章详情", httpMethod = "GET", response = Result.class, notes = "我的文章详情")
//    public Result selectMyArticleInfo(Long id) {
//        return articleService.selectMyArticleInfo(id);
//    }
}
